package com.xgxf.server.controller;

import com.xgxf.server.common.BaseQuery;
import com.xgxf.server.common.JsonResult;
import com.xgxf.server.pojo.ParameterDetailsQuery;
import com.xgxf.server.pojo.StandardValues;
import com.xgxf.server.service.IParameterDetailsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/parameterDetails")
public class ParameterDetailsController {

    @Autowired
    private IParameterDetailsService service;

    @ApiOperation("获取列表")
    @GetMapping("/getList")
    public JsonResult getList(BaseQuery parameterQuery){
        return service.getList(parameterQuery);
    }

    /**
     * String[] ids
     * 传参名为id，实为type型号
     */
    @ApiOperation("删除列表")
    @GetMapping("/deleteids")
    public JsonResult getList(int userId, String userName, String[] ids){
        return service.deleteId(userId, userName, ids);
    }

    @ApiOperation("修改某一项")
    @GetMapping("/updateCondition")
    public JsonResult updateCondition(int userId, String userName, StandardValues params){
        return service.updateCondition(userId, userName, params);
    }

    @ApiOperation("增加某一项列表")
    @GetMapping("/addCondition")
    public JsonResult addCondition(int userId, String userName, StandardValues params){
        return service.insertForkLiftById(userId, userName, params);
    }

    @ApiOperation("查询具体型号的检测标准")
    @GetMapping("/getTypeDetails")
    public JsonResult getTypeDetails(ParameterDetailsQuery parameterQuery){
        return service.getTypeDetails(parameterQuery);
    }

    /**
     *
     * @param type 剪叉车型号
     * @return
     */
    @ApiOperation("新增检测标准时导入原有型号参数")
    @GetMapping("/getImportValues")
    public JsonResult getImportValues(String type){
        return service.getImportValues(type);
    }



    @GetMapping("/getParameterTypeList")
    @ApiOperation("查询parameterdetail的列表")
    public JsonResult getParameterTypeList(){
        ArrayList<String> list=service.getParameterTypeList();
        return JsonResult.success(list);
    }
}
